package com.zx.idc.backend.gui.base.house;


import com.zx.idc.backend.gui.common.BaseApi;
import com.zx.idc.backend.gui.common.Result;
import com.zx.idc.ds.base.house.service.IBaseHousesHoldInfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 占用机房信息管理 前端控制器
 * </p>
 *
 * @author rxliuli
 * @since 2019-01-31
 */
@RestController
@RequestMapping("/api/baseHousesHoldInfo")
public class BaseHousesHoldInfoController extends BaseApi {
    @Autowired
    private IBaseHousesHoldInfoService service;

    /**
     * 删除占用机房及其关联
     *
     * @param id 实体主键
     * @return 删除是否成功，需要以 {@link Result#getData()} 作为判断标准
     */
    @PostMapping("/delete/{id}")
    @RequiresPermissions("basic-data:base-customer:edit")
    public Result<Boolean> delete(@PathVariable("id") Long id) {
        String msg;
        try {
            return success(service.deleteAssociationById(id));
        } catch (Exception e) {
            msg = e.getMessage();
            log.error("删除应用服务或占用机房信息异常", e);
        }
        return error(msg);
    }
}

